﻿@using MarkdownWebPages;
@using System.Text.RegularExpressions;

@functions {
    string ProcessIncludes(string content, MarkdownWebPage page) {
        return Regex.Replace(content, @"^@include\((?<include>~/.*?)\)", match => MarkdownWebPage.RenderFile(match.Groups["include"].Value, page), RegexOptions.Multiline);
    }

    string ProcessComments(string content, MarkdownWebPage page) {
        return Regex.Replace(content, @"^//(.*?)$", match => String.Empty, RegexOptions.Multiline);
    }
}

@{
    MarkdownWebPage.TransformUrls = true;
    MarkdownWebPage.AlterBehaviors(b => b.Clear());
    MarkdownWebPage.AlterBehaviors(b => b.Add(ProcessIncludes));
    MarkdownWebPage.AlterBehaviors(b => b.Add(ProcessComments));
}


